package com.th.cash.util

import android.content.Context
import android.os.Build
import android.provider.Settings
import android.text.TextUtils
import com.th.basemodel.ext.gotoActivity
import com.th.basemodel.utils.AppUtil
import com.th.basemodel.utils.CommUtils
import com.th.cash.th2.h5.H5Activity
import com.th.cash.th2.product.ProductActivity
import com.th.cash.th2.set.SetActivity

class ActivityRouter {

    companion object {

        fun next(context: Context, scheme: String) {
            if (TextUtils.isEmpty(scheme)) {
                return
            }

            if (scheme.startsWith("http")) {
                context.gotoActivity<H5Activity>(
                    bundle = arrayOf<Pair<String, Any?>>(
                        Pair(
                            H5Activity.URL,
                            addParams(scheme)
                        )
                    )
                )
            } else if (scheme.startsWith("openapp://blwfqmqjJump/fivnqmqd5")) {
                context.gotoActivity<ProductActivity>(
                    bundle = arrayOf<Pair<String, Any?>>(
                        Pair(ProductActivity.URI, scheme)
                    )
                )
            } else if (scheme.startsWith("openapp://blwfqmqjJump/bgngbtes2")) {
                context.gotoActivity<SetActivity>()
            }
        }

        private fun addParams(scheme: String): String {
            var newUrl = if (scheme.contains("?")) {
                scheme.plus("&")
            } else {
                scheme.plus("?")
            }

            newUrl = newUrl.plus("RnqcoCVToadeaterTRdhDOo=android")
                .plus("&UBbFTkISpasmicSVzlMwh=${AppUtil.getVersionName()}")
                .plus("&OvzyBEVUncleannessSpwdJyB=${Build.MODEL}")
                .plus(
                    "&ERTHvSLNowaysYTCweiv=${
                        Settings.Secure.getString(
                            CommUtils.getContext().getContentResolver(), Settings.Secure.ANDROID_ID
                        )
                    }"
                )
                .plus("&WJkzerdPalatablyEDruioY=${Build.VERSION.RELEASE}")
                .plus("&qRRRvKwDragonesqueJcXmmuC=th")
                .plus("&tXkcBaQPayslipQlFCHUN=${AppUtil.sessionId}")
                .plus("&ATQbfadAllowedlyQCdkBOz=${CommUtils.getContext().packageName}")
                .plus("&BOmgDtGNyalaZJFsybd=${AppUtil.adid}")
                .plus("&esKltshCorrodyDNQBuyO=${AppUtil.userPhone}")
                .plus("&QrBtyVyProprietressOWxNoHy=")

            return newUrl
        }
    }
}